﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;

namespace PlaceOrder_Admin.Converters
{
    public class MessageZeroConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 将值转换成整数
            if (int.TryParse(value.ToString(), out int count))
            {
                // 如果值为 0，则返回 Collapsed，否则返回 Visible
                return count == 0 ? Visibility.Collapsed : Visibility.Visible;
            }

            // 默认情况下返回 Visible
            return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
